﻿@{
    //page title
    ViewBag.Title = T("Admin.ContentManagement.Forums.Manage").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption">
                    <i class="fa fa-forumbee"></i>
                    @T("Admin.ContentManagement.Forums.Manage")
                </div>
                <div class="actions btn-group btn-group-devided">
                    <a href="@Url.Action("CreateForumGroup")" class="btn green">@T("Admin.ContentManagement.Forums.ForumGroup.CreateForumGroup")</a>
                    <a href="@Url.Action("CreateForum")" class="btn blue">@T("Admin.ContentManagement.Forums.Forum.CreateForum")</a>
                    <vc:admin-widget widget-zone="forum_list_buttons" additional-data="null" />
                </div>

            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="forumgroup-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    $(document).ready(function() {
        $("#forumgroup-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("ForumGroupList", "Forum"))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            //details grid
            detailInit: detailInit,
            scrollable: false,
            columns: [
                {
                    field: "Name",
                    title: "@T("Admin.ContentManagement.Forums.ForumGroup.Fields.Name")",
                    width: 300,
                    template: '<a class="k-link" href="EditForumGroup/#=Id#">#=kendo.htmlEncode(Name)#</a>',
                }, {
                    field: "DisplayOrder",
                    title: "@T("Admin.ContentManagement.Forums.ForumGroup.Fields.DisplayOrder")",
                    width: 100
                }, {
                    field: "CreatedOn",
                    title: "@T("Admin.ContentManagement.Forums.ForumGroup.Fields.CreatedOn")",
                    width: 200,
                    type: "date",
                    format: "{0:G}"
                }
            ]
        });
    });

    //details grid
    function detailInit(e) {
        $("<div/>").appendTo(e.detailCell).kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("ForumList", "Forum"))?forumGroupId=" + e.data.Id,
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            scrollable: false,
            sortable: true,
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            columns: [
                {
                    field: "Name",
                    title: "@T("Admin.ContentManagement.Forums.Forum.Fields.Name")",
                    width: 300,
                    template: '<a class="k-link" href="EditForum/#=Id#">#=kendo.htmlEncode(Name)#</a>',
                },{
                    field: "DisplayOrder",
                    title: "@T("Admin.ContentManagement.Forums.Forum.Fields.DisplayOrder")",
                    width: 150
                },{
                    field: "CreatedOn",
                    title: "@T("Admin.ContentManagement.Forums.Forum.Fields.CreatedOn")",
                    width: 150,
                    type: "date",
                    format: "{0:G}"
                }
            ]
        });
    }
</script>
